<template>
  <div class="main-wrapper">
    <canvas ref="fluidCanvas" class="background-canvas" id="IntroduceCanvas"></canvas>
    <div class="content-overlay">
      <div class="container">
        <div class="hero-section">
          <div class="hero-content">
            <h1 class="site-title">LYQ</h1>
            <p class="site-subtitle spotlight-text">PRESS START</p>
          </div>
        </div>
        <div class="scroll-down">
          <i class="ivu-icon ivu-icon-ios-arrow-down" @click="showNext"></i>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'IntroducePage',
  emits: ['showNext'],
  data() {
      return {
        fluidCleanup: null
      }
    },
    methods: {
      showNext() {
        this.$emit('showNext');
      }
    },
    mounted() {
      // 使用动态导入加载流体模拟
      import('@/utils/background.js')
        .then((module) => {
          if (typeof module.initFluidSimulation === 'function') {
            // 保存清理函数
            this.fluidCleanup = module.initFluidSimulation(this.$refs.fluidCanvas);
          }
          
          // 启用鼠标事件监听
          if (typeof module.enableMouseMoveListener === 'function') {
            module.enableMouseMoveListener();
          }
        })
        .catch((error) => {
          console.error('Failed to load fluid simulation:', error);
        });
    },
    beforeUnmount() {
      // 组件卸载时清理流体模拟
      if (this.fluidCleanup) {
        this.fluidCleanup();
        this.fluidCleanup = null;
      }
      
      // 禁用鼠标事件监听
      import('@/utils/background.js')
        .then((module) => {
          if (typeof module.disableMouseMoveListener === 'function') {
            module.disableMouseMoveListener();
          }
        })
        .catch((error) => {
          console.error('Failed to load fluid simulation:', error);
        });
    }
}
</script>

<style scoped>
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  
  body, html {
    height: auto;
    min-height: 100vh; 
    font-family: 'Inter', sans-serif;
    color: #fff;
  }
  
  .main-wrapper {
    position: relative;
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
  }
  
  .background-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
  }
  
  .content-overlay {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    width: 100%;
    pointer-events: none;
  }
  
  .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
  }
  
  .hero-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    pointer-events: none;
  }
  
  .hero-content {
    text-align: center;
    padding: 20px;
    pointer-events: none;
  }
  
  .site-title {
    font-size: clamp(2rem, 12vw, 8rem); 
    font-weight: 100;
    margin-bottom: 40px;
    color: white;

    animation: fadeIn 1.5s ease-in-out;
    transition: 
      font-size 0.5s ease,   
      transform 0.5s ease,  
      margin 0.5s ease;  
  }

  .site-subtitle.spotlight-text {
    font-size: clamp(0.5rem, 3vw, 2rem); 
    color: rgba(255, 255, 255, 0.3); 
    position: relative;
    display: inline-block;
    overflow: hidden; 
    letter-spacing: 2px;
    font-weight: 200;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.8) 50%, rgba(255,255,255,0) 100%);
    background-size: 200% 100%;
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    
    opacity: 0;                  
    transform: translateY(20px); 
    animation: 
      fadeIn 1.5s ease-in-out forwards,   
      spotlight 5s infinite linear;       
    animation-delay: 0.3s, 0s; 

    transition: 
      font-size 0.5s ease,   
      transform 0.5s ease,  
      margin 0.5s ease;  
    pointer-events: none;
  }
  
  @keyframes spotlight {
    0% {
      background-position: -200% 0;
    }
    100% {
      background-position: 200% 0;
    }
  }
  .scroll-down {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    animation: bounce 2s infinite;
    pointer-events: auto;
    z-index: 3;
  }
  
  .scroll-down .ivu-icon {
    pointer-events: auto;
    font-size: 24px;
    color: rgba(255, 255, 255, 0.7);
  }
  
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
  }
  
  @keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
  }
  canvas {
    width: 100%;
    height: 100%;
    display: block;
  }
  
  .dg {
    display: none !important;
  }
</style>